package com.hmall.order.controller;

import com.hmall.common.dto.ResultDTO;
import com.hmall.order.pojo.OrderByPojo;
import com.hmall.order.pojo.OrderDetail;
import com.hmall.order.servie.OrderService;
import com.hmall.order.vo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/order")
    public Long createOrder(@RequestBody Order order) {
        return orderService.createOrder(order);
    }

    @GetMapping("/order/{orderId}")
    public OrderByPojo getOrder(@PathVariable Long orderId){
        return orderService.getOrder(orderId);
    }

//    /**
//     * 查询订单支付状态
//     * @param orderId
//     * @return
//     */
//    @GetMapping("/order/status/{orderId}")
//    public Integer getStatus(@PathVariable("orderId")Long orderId){
//        return orderService.getStatus(orderId);
//}

    @PutMapping("/pay/{orderId}")
    public ResultDTO pay(@PathVariable("orderId") Long orderId, @RequestBody String password){
        return orderService.pay(orderId,password);
    }
}
